package com.lemurian.bankdata.lite.logger;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;

import com.lemurian.bankdata.lite.utils.BankDataCommons;

public class BankDataLogger extends Logger {

	public static final String LOG_SEPARATOR = "=======================================================================================================================================";
    public static final String LOG_SEPARATOR_SMALL = "---------------------------------------------------------------------------------------------------------------------------------------";
	
	protected BankDataLogger(String name) {
		super(name);
	}
	
	public BankDataLogger(String name, String resourceBundle) {
        super(name);
    }

	private static BankDataCustomerLogFactory myFactory = new BankDataCustomerLogFactory();

    public static synchronized BankDataLogger getLogger(String name) {
        name = BankDataCommons.getBankDataConfig().getString("project.name").concat(" : ").concat(name);
        return (BankDataLogger) Logger.getLogger(name, myFactory);
    }

    public String preparePrefix(Object p, String msg) {
        try {

        } catch (Throwable ex) {
            ex.printStackTrace();
            return "";
        }
        return "";

    }

    public String getFormattedString(String msg, Object input, Object... args) {
        return String.format(preparePrefix(input, msg), args);
    }

    public String getFormattedString(String msg, Object... args) {
        return String.format(msg, args);
    }

    public void config(String msg, Object... args) {
        if (isInfoEnabled()) {
            log(Level.INFO, getFormattedString(msg, args));
        }
    }

    public void config(Object prefixInfo, String msg, Object... args) {
        if (isInfoEnabled()) {
            log(Level.INFO, getFormattedString(msg, prefixInfo, args));
        }
    }

    public void fine(String msg, Object... args) {
        if (isDebugEnabled()) {
            log(Level.DEBUG, getFormattedString(msg, args));
        }
    }

    public void fine(Object prefixInfo, String msg, Object... args) {
        if (isDebugEnabled()) {
            log(Level.DEBUG, getFormattedString(msg, prefixInfo, args));
        }
    }

    public void finer(Object prefixInfo, String msg, Object... args) {
        if (isDebugEnabled()) {
            log(Level.DEBUG, getFormattedString(msg, prefixInfo, args));
        }
    }

    public void finest(String msg, Object... args) {
        if (isDebugEnabled()) {
            log(Level.DEBUG, getFormattedString(msg, args));
        }
    }

    public void finest(Object prefixInfo, String msg, Object... args) {
        if (isDebugEnabled()) {
            log(Level.DEBUG, getFormattedString(msg, prefixInfo, args));
        }
    }

    public void severe(String msg, Object... args) {
        log(Level.ERROR, getFormattedString(msg, args));
    }

    public void severe(Throwable th, String msg, Object... args) {
        log(Level.ERROR, getFormattedString(msg, args), th);
    }

    public void severe(Object prefixInfo, Throwable th, String msg, Object... args) {
        log(Level.ERROR, getFormattedString(msg, prefixInfo, args), th);
    }

    public void severe(Object prefixInfo, String msg, Object... args) {
        log(Level.ERROR, getFormattedString(msg, prefixInfo, args));
    }


    public void info(Throwable th, String msg, Object... args) {
        if (isInfoEnabled()) {
            log(Level.INFO, getFormattedString(msg, args), th);
        }
    }

    public void info(String msg) {
        if (isInfoEnabled()) {
            log(Level.INFO, msg);
        }
    }

    public void sInfo(String msg, Object... args) {
        if (isInfoEnabled()) {
            log(Level.INFO, getFormattedString(msg, args));
        }
    }

    public void info(Object prefixInfo, Throwable th, String msg, Object... args) {
        if (isInfoEnabled()) {
            log(Level.INFO, getFormattedString(msg, prefixInfo, args), th);
        }
    }

    public void info(Object prefixInfo, String msg, Object... args) {
        if (isInfoEnabled()) {
            log(Level.INFO, getFormattedString(msg, prefixInfo, args));
        }
    }


    public void warning(Throwable th, String msg, Object... args) {

        log(Level.WARN, getFormattedString(msg, args), th);
    }

    public void warn(String msg) {
        log(Level.WARN, msg);
    }

    public void warning(String msg, Object... args) {

        log(Level.WARN, getFormattedString(msg, args));
    }

    @Override
    public void setLevel(Level newLevel) throws SecurityException {
        super.setLevel(newLevel);
    }

    public void debug(String msg, Object... args) {
        if (isDebugEnabled()) {
            log(Level.DEBUG, getFormattedString(msg, args));
        }
    }

    public void debug(Object prefixInfo, String msg, Object... args) {
        if (isDebugEnabled()) {
            log(Level.DEBUG, getFormattedString(msg, prefixInfo, args));
        }
    }
}
